package com.hzqy.service.commons;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.hzqy.commons.utils.HttpUtil;
import com.hzqy.web.vo.commons.InterfaceReqeustVo;

@Service
public class InterfaceRequestService {
	private static final long serialVersionUID = 1L;
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	public Map<String,Object> selectInterfaceList(InterfaceReqeustVo interfaceReqeustVo) {
		Map<String,Object> map=new HashMap<String,Object>();
		if(interfaceReqeustVo==null){
			map.put("msg", "参数错误");
			map.put("flag", -1);
		}else{
			if("post".equals(interfaceReqeustVo.getRequestType())){
				Map<String,String> result=HttpUtil.post(interfaceReqeustVo.getUrl(),interfaceReqeustVo.getDatas());
				if("1".equals(result.get("success"))){
					map.put("msg", result.get("msg"));
					map.put("flag", 0);
				}else{
					map.put("msg", "数据获取失败："+result.get("msg"));
					map.put("flag", -1);
				}
			}else{
				Map<String,String> result=HttpUtil.get(interfaceReqeustVo.getUrl());
				if("1".equals(result.get("success"))){
					map.put("msg", result.get("msg"));
					map.put("flag", 0);
				}else{
					map.put("msg", "数据获取失败："+result.get("msg"));
					map.put("flag", -1);
				}
			}
		}
		return map;
	}

}
